var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("LoadRes"),
    n = e("AD"),
    i = cc._decorator,
    r = i.ccclass,
    s = i.property,
    l = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.image_node = null),
                (t.ad_info = null),
                (t.close_btn = null),
                (t.nativeInfo = null),
                (t.closeCallBack = function () { }),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.onEnable = function () {
                this.initView(), this.addEvent();
            }),
            (t.prototype.showNativeCall = function (e) {
                this.closeCallBack = e;
            }),
            (t.prototype.initView = function () {
                var e = this;
                if (
                    ((this.nativeInfo = n.default.getInstance().getNativeImageInfo()),
                        console.log("==========原生大图广告信息==============", this.nativeInfo),
                        this.nativeInfo &&
                        this.nativeInfo.adId &&
                        (this.nativeInfo.Native_icon || this.nativeInfo.Native_BigImage))
                ) {
                    n.default.getInstance().reportNativeImageAdShow();
                    var t = this.nativeInfo.Native_BigImage;
                    t || (t = this.nativeInfo.Native_icon),
                        a.default.loadResCustom(t, function (t) {
                            (e.image_node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t)),
                                (e.image_node.active = !0),
                                (e.ad_info.active = !0);
                        }),
                        (this.ad_info.children[0].getComponent(cc.Label).string = "" + this.nativeInfo.clickBtnTxt);
                } else
                    this.closeCallBack && this.closeCallBack(),
                        (this.ad_info.active = !1),
                        (this.image_node.active = !1);
                setTimeout(function () {
                    e.initView();
                }, 3e4);
            }),
            (t.prototype.addEvent = function () {
                this.image_node.on("click", this.nativeClick, this),
                    this.ad_info.on("click", this.nativeClick, this),
                    this.close_btn.on("click", this.closeThisNode, this);
            }),
            (t.prototype.nativeClick = function () {
                n.default.getInstance().nativeImageClick();
            }),
            (t.prototype.closeThisNode = function () {
                n.default.getInstance().getNativeImageErrorControl()
                    ? this.nativeClick()
                    : (this.closeCallBack && this.closeCallBack(),
                        (this.ad_info.active = !1),
                        (this.image_node.active = !1));
            }),
            oo([s(cc.Node)], t.prototype, "image_node", void 0),
            oo([s(cc.Node)], t.prototype, "ad_info", void 0),
            oo([s(cc.Node)], t.prototype, "close_btn", void 0),
            oo([r], t)
        );
    })(cc.Component);
o.default = l;
